/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   11.05.2010
 * @version SVN: $Id: ClientSessionInfo.java 120 2010-05-11 20:11:01Z christian-kerl@web.de $
 */
package org.cakis.server.service.session;

import java.io.Serializable;
import java.util.*;

/**
 * ClientSessionInfo stores information and state of a {@link ClientSession}.
 *
 * @author Christian Kerl
 */
public class ClientSessionInfo implements Serializable {
    public static enum State {
        Started,
        Inited,
        Invalid,
    }

    private static final long serialVersionUID = 1L;

    private UUID id;
    private String clientId;
    private Date lastAccess;
    private State state;

    public UUID getId() {
        return id;
    }

    private void setId(UUID id) {
        this.id = id;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public Date getLastAccess() {
        return lastAccess;
    }

    public void setLastAccess(Date lastAccess) {
        this.lastAccess = lastAccess;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    public ClientSessionInfo() {
        setId(UUID.randomUUID());
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ClientSessionInfo other = (ClientSessionInfo) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }


}
